#ifndef LATLONDIALOG_H
#define LATLONDIALOG_H

#include "rotatingdialog.h"
#include <QtGui>
#include "configuration.h"

class FTCheckBox;
class FTRadioButton;
class FTLineEdit;
class FTPushButton;
class FTLabel;

class LatLonDialog : public RotatingDialog
{
    Q_OBJECT
public:
    explicit LatLonDialog(double lat = 0.0,
                          double lon = 0.0,
                          Configuration::coordinate_format df = Configuration::decimal);
    ~LatLonDialog();

    bool execLatLon(double&, double&);

private slots:
    void setDec();
    void setDms();
    void setDm();
    void setUtm();

private:
    void dataToDouble();
    void doubleToData();

    void buildTop();
    void buildDec();
    void buildDms();
    void buildDm();
    void buildUtm();

    double latitude;
    double longitude;
    Configuration::coordinate_format activeFormat;

    FTPushButton* confirmButton;
    FTPushButton* cancelButton;
    QButtonGroup fbg;
    FTRadioButton* format_ddd_ddddddd;
    FTRadioButton* format_ddd_mm_ss;
    FTRadioButton* format_ddd_mm;
    FTRadioButton* format_utm;

    QStackedWidget* formats;

    // decimal format
    QWidget* dec;
    FTLabel* dec_latitudeLabel;
    FTLabel* dec_longitudeLabel;
    FTLineEdit* dec_lat;
    FTLineEdit* dec_lon;
    FTCheckBox* dec_north;
    FTCheckBox* dec_south;
    QButtonGroup dec_ns;
    FTCheckBox* dec_east;
    FTCheckBox* dec_west;
    QButtonGroup dec_ew;

    // ddd mm ss format
    QWidget* dms;
    FTLabel* dms_latitudeLabel;
    FTLabel* dms_longitudeLabel;
    FTLineEdit* dms_lat;
    FTLineEdit* dms_lat_minutes;
    FTLineEdit* dms_lat_seconds;
    FTLineEdit* dms_lon;
    FTLineEdit* dms_lon_minutes;
    FTLineEdit* dms_lon_seconds;
    FTCheckBox* dms_north;
    FTCheckBox* dms_south;
    QButtonGroup dms_ns;
    FTCheckBox* dms_east;
    FTCheckBox* dms_west;
    QButtonGroup dms_ew;

    // dm format
    QWidget* dm;
    FTLabel* dm_latitudeLabel;
    FTLabel* dm_longitudeLabel;
    FTLineEdit* dm_lat;
    FTLineEdit* dm_lat_minutes;
    FTLineEdit* dm_lon;
    FTLineEdit* dm_lon_minutes;
    FTCheckBox* dm_north;
    FTCheckBox* dm_south;
    QButtonGroup dm_ns;
    FTCheckBox* dm_east;
    FTCheckBox* dm_west;
    QButtonGroup dm_ew;

    // UTM format
    QWidget* utm;
    FTLabel* utm_northingLabel;
    FTLabel* utm_eastingLabel;
    FTLabel* utm_zoneLabel;
    FTLineEdit* utm_northing;
    FTLineEdit* utm_easting;
    FTLineEdit* utm_zone;


    QLayout* createVertical();
};

#endif // LATLONDIALOG_H
